/**
 */
package audiomixer.impl;

import audiomixer.AudiomixerPackage;
import audiomixer.Canal;
import audiomixer.Funcionalidad;
import audiomixer.Pista;
import audiomixer.funcionalidades;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EDataTypeUniqueEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Canal</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link audiomixer.impl.CanalImpl#getPista <em>Pista</em>}</li>
 *   <li>{@link audiomixer.impl.CanalImpl#getId <em>Id</em>}</li>
 *   <li>{@link audiomixer.impl.CanalImpl#getRepresentacion <em>Representacion</em>}</li>
 *   <li>{@link audiomixer.impl.CanalImpl#getFuncionalidades <em>Funcionalidades</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CanalImpl extends EObjectImpl implements Canal {
	/**
	 * The cached value of the '{@link #getPista() <em>Pista</em>}' reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPista()
	 * @generated
	 * @ordered
	 */
	protected Pista pista;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final int ID_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected int id = ID_EDEFAULT;

	/**
	 * The default value of the '{@link #getRepresentacion() <em>Representacion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRepresentacion()
	 * @generated
	 * @ordered
	 */
	protected static final String REPRESENTACION_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getRepresentacion() <em>Representacion</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getRepresentacion()
	 * @generated
	 * @ordered
	 */
	protected String representacion = REPRESENTACION_EDEFAULT;

	/**
	 * The cached value of the '{@link #getFuncionalidades() <em>Funcionalidades</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFuncionalidades()
	 * @generated
	 * @ordered
	 */
	protected EList<Funcionalidad> funcionalidades;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected CanalImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return AudiomixerPackage.Literals.CANAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Pista getPista() {
		if (pista != null && pista.eIsProxy()) {
			InternalEObject oldPista = (InternalEObject)pista;
			pista = (Pista)eResolveProxy(oldPista);
			if (pista != oldPista) {
				if (eNotificationRequired())
					eNotify(new ENotificationImpl(this, Notification.RESOLVE, AudiomixerPackage.CANAL__PISTA, oldPista, pista));
			}
		}
		return pista;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Pista basicGetPista() {
		return pista;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setPista(Pista newPista) {
		Pista oldPista = pista;
		pista = newPista;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AudiomixerPackage.CANAL__PISTA, oldPista, pista));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(int newId) {
		int oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AudiomixerPackage.CANAL__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getRepresentacion() {
		return representacion;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setRepresentacion(String newRepresentacion) {
		String oldRepresentacion = representacion;
		representacion = newRepresentacion;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, AudiomixerPackage.CANAL__REPRESENTACION, oldRepresentacion, representacion));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Funcionalidad> getFuncionalidades() {
		if (funcionalidades == null) {
			funcionalidades = new EDataTypeUniqueEList<Funcionalidad>(Funcionalidad.class, this, AudiomixerPackage.CANAL__FUNCIONALIDADES);
		}
		return funcionalidades;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case AudiomixerPackage.CANAL__PISTA:
				if (resolve) return getPista();
				return basicGetPista();
			case AudiomixerPackage.CANAL__ID:
				return getId();
			case AudiomixerPackage.CANAL__REPRESENTACION:
				return getRepresentacion();
			case AudiomixerPackage.CANAL__FUNCIONALIDADES:
				return getFuncionalidades();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case AudiomixerPackage.CANAL__PISTA:
				setPista((Pista)newValue);
				return;
			case AudiomixerPackage.CANAL__ID:
				setId((Integer)newValue);
				return;
			case AudiomixerPackage.CANAL__REPRESENTACION:
				setRepresentacion((String)newValue);
				return;
			case AudiomixerPackage.CANAL__FUNCIONALIDADES:
				getFuncionalidades().clear();
				getFuncionalidades().addAll((Collection<? extends Funcionalidad>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case AudiomixerPackage.CANAL__PISTA:
				setPista((Pista)null);
				return;
			case AudiomixerPackage.CANAL__ID:
				setId(ID_EDEFAULT);
				return;
			case AudiomixerPackage.CANAL__REPRESENTACION:
				setRepresentacion(REPRESENTACION_EDEFAULT);
				return;
			case AudiomixerPackage.CANAL__FUNCIONALIDADES:
				getFuncionalidades().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case AudiomixerPackage.CANAL__PISTA:
				return pista != null;
			case AudiomixerPackage.CANAL__ID:
				return id != ID_EDEFAULT;
			case AudiomixerPackage.CANAL__REPRESENTACION:
				return REPRESENTACION_EDEFAULT == null ? representacion != null : !REPRESENTACION_EDEFAULT.equals(representacion);
			case AudiomixerPackage.CANAL__FUNCIONALIDADES:
				return funcionalidades != null && !funcionalidades.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(", representacion: ");
		result.append(representacion);
		result.append(", funcionalidades: ");
		result.append(funcionalidades);
		result.append(')');
		return result.toString();
	}

} //CanalImpl
